<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!<DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="/style/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script type="text/javascript" src="/js/plugins/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/commonAll.js"></script>
    <title>叩丁狼教育PSS（演示版）-账户管理</title>
    <style>
        .alt td {
            background: black !important;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $("[name=deptno] option").each(function (index, item) {
                if ($(item).val() ==${qo.deptno}) {
                    $(item).prop("selected", true)
                }
            })
        })
    </script>
    <script>
        $(function () {
            $(".btn_deleteAll").click(function () {
                var url = $(this).data("deleteurl")
                var dialog = $.dialog
                dialog({
                    title: "提示",
                    content: "是否删除这些数据",
                    ok: function () {
                        var checkeds = $(".acb:checked")
                        if (checkeds.size() === 0) {
                            dialog({
                                title: "提示",
                                content: "请选择数据后再删除",
                            })
                            return;
                        }
                        var ids = $.map(checkeds, function (item) {
                            return $(item).data("eid");
                        })
                        $.post(url, {ids: ids}, function (data) {
                            if (data.success) {
                                dialog({
                                    title: "提示",
                                    content: data.msg,
                                    ok: function () {
                                        window.location.href = "/employee/list.do";
                                    }
                                })
                            } else {
                                dialog.button({
                                    name: "确定"
                                })
                            }
                        })
                    }
                })
            });
        })

    </script>
</head>
<body>
<form id="searchForm" action=/employee/list.do method="post">
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">搜索</div>
                    <div id="box_center">
                        姓名/邮箱
                        <input type="text" class="ui_input_txt02" name="keyword" value="${qo.keyword}"/>
                        所属部门
                        <select class="ui_select01" name="deptno">
                            <option value="-1">请选择</option>
                            <c:forEach items="${dept}" var="dept">
                                <option value="${dept.id}">${dept.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div id="box_bottom">
                        <input type="button" value="查询" class="ui_input_btn01 btn_select"/>
                        <input type="button" value="新增" class="ui_input_btn01 btn_input btn_url"
                               data-url="/employee/input.do"/>
                        <input type="button" value="批量删除" class="ui_input_btn01 btn_deleteAll"
                               data-deleteurl="/employee/deleteAll.do"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <th width="30"><input type="checkbox" id="all"/></th>
                        <th>编号</th>
                        <th>用户名</th>
                        <th>EMAIL</th>
                        <th>年龄</th>
                        <th>所属部门</th>
                        <th>角色</th>
                        <th></th>
                    </tr>
                    <tbody>
                    <c:forEach items="${result.data}" var="data">
                        <tr>
                            <td><input type="checkbox" name="IDCheck" class="acb" data-eid="${data.id}"/></td>
                            <td>${data.id}</td>
                            <td>${data.name}</td>
                            <td>${data.email}</td>
                            <td>${data.age}</td>
                            <td>${data.dept.name}</td>
                                <%--<td>${data.roleName}</td>--%>
                            <td>
                                <a href="javascript:" class="btn_url" data-url="/employee/input.do?id=${data.id}">编辑</a>
                                <a href="javascript:" class="btn_delete"
                                   data-url="/employee/delete.do?id=${data.id}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="ui_tb_h30">
                <%@include file="../common/common.jsp" %>
            </div>
        </div>
    </div>
</form>
</body>
</html>
